package org.dreamwork.cai.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.dreamwork.cai.srf.ServiceRouteItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 11-11-17
 * Time: 下午5:01
 */
public class DynamicProxyCallback implements MethodInterceptor {
    private final Logger logger = LoggerFactory.getLogger (DynamicProxyCallback.class);

    private final ServiceRouteItem sri;

    public DynamicProxyCallback (ServiceRouteItem sri) {
        this.sri = sri;
    }

    @Override
    public Object intercept (Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        if (logger.isTraceEnabled ()) {
            logger.trace ("obj    = {}", obj);
            logger.trace ("method = {}", method);
            logger.trace ("args   = {}", Arrays.toString (args));
            logger.trace ("proxy  = {}", proxy);
        }
        return null;
    }

/*
    public Object intercept (Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        if (logger.isTraceEnabled ()) {
            logger.trace ("method = {}", method);
        }
        return methodProxy.invokeSuper (o, objects);
    }
*/
}
